function r(url, data, successFun, successErrorFun, failFun, completeFun, header, method) {
  var reqObj = {};
  reqObj.url = url;
  reqObj.data = data;

  //默认头为json 
  reqObj.header = { 'Content-Type': 'application/json' };
  if (header) {
    //覆盖header 
    reqObj.header = header;
  }


  if (method) {
    reqObj.method = method;
  }
  reqObj.success = function (res) {
    var returnData = res.data; //将微信端结果过滤,获取服务端返回的原样数据 
    var status = returnData.status; //按接口约定,返回status时,才调用成功函数 
    ////console.log(res);
    //正常执行的业务函数 
    if (status == true) {
      if (successFun) {
        var dts = returnData.data;
        successFun(dts);//回调，相当于获取到data后直接在回调里面处理赋值数据 
      }
    } else if (status == false) {
      var msg = returnData.msg;
      if (!successErrorFun) {
        //console.log(msg);
      } else {
        successErrorFun(msg);
      }

    } else {
      //console.log("服务端没有按照接口约定格式返回数据");
    }


  }
  reqObj.fail = function (res) {
    if (failFun) {
      failFun(res);
    }
  }
  reqObj.complete = function (res) {
    if (completeFun) {
      completeFun(res);
    }
  }


  wx.request(reqObj);
}

module.exports = {
  r: r
} 